//
//  ViewController.m
//  dangdang
//
//  Created by air on 15/12/7.
//  Copyright © 2015年 luweijie. All rights reserved.
//

#import "HomepageViewController.h"
#import "KeyboardViewController.h"
#import "OrderViewController.h"
#import "PersonalViewController.h"
#import "LoginViewController.h"
#import "LVRecordTool.h"
#import "CityViewController.h"
#import <AMapLocationKit/AMapLocationKit.h>
#import "MessageViewController.h"
#import "PrologueViewController.h"
#import "UIImageView+WebCache.h"

@interface HomepageViewController ()<LVRecordToolDelegate, AMapLocationManagerDelegate>

{
    AMapLocationManager * _mapLocationManager;
}

@property (nonatomic, strong) NSMutableArray * cityArray;
@property (nonatomic, strong) NSArray *imagesData;
@property (nonatomic, strong) NSTimer * myTimer;
@property (nonatomic, strong) NSMutableArray * imageAddressArray;
@property (nonatomic, strong) NSMutableData * imageData;
@property (nonatomic, strong) NSMutableArray * imageViewArray;
@property (nonatomic, strong) UIScrollView * myScroll;
/** 录音工具 */
@property (nonatomic, strong) LVRecordTool *recordTool;

@end

@implementation HomepageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    if ([userObject.homeString isEqualToString:@"1"]) {
        [self scrollViewLayout];
    }
    
    [self updateUI];
}

- (void)configMapView
{
    _mapLocationManager = [[AMapLocationManager alloc] init];
    
    _mapLocationManager.delegate = self;
    
//     [_mapLocationManager setPausesLocationUpdatesAutomatically:NO];
    
    [_mapLocationManager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
    
    [_mapLocationManager requestLocationWithReGeocode:YES completionBlock:^(CLLocation *location, AMapLocationReGeocode *regeocode, NSError *error) {
        if (error)
        {
            NSLog(@"locError:{%ld - %@};", (long)error.code, error.localizedDescription);
            
            if (error.code == AMapLocationErrorLocateFailed)
            {
                return;
            }
        }
        
        //        NSLog(@"location:%@", location);
        if (regeocode)
        {
//            _startPoint = [AMapNaviPoint locationWithLatitude:location.coordinate.latitude longitude:location.coordinate.longitude];
            NSString * token = userObject.accessToken;
            NSString * userIDString = userObject.userID;
            NSString * lat = [NSString stringWithFormat:@"%f", location.coordinate.latitude];
            NSString * lng = [NSString stringWithFormat:@"%f", location.coordinate.longitude];
            
            NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
            [params setObject:token forKey:@"token"];
            [params setObject:userIDString forKey:@"uid"];
            [params setObject:lat forKey:@"lat"];
            [params setObject:lng forKey:@"lng"];
                
            [self postRequestWithMethodName:@"order/upload_express_postion" andParams:params andSender:nil];
        }
    }];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    if ([userObject.type isEqualToString:@"1"]) {
        _orderImageView.image = [UIImage imageNamed:@"hk_grab.png"];
    }
    
    if ([cityObject.sucessCity isEqualToString:@"city"]) {
        [self addBottomView];
    }
    
    if (cityObject.city == nil || [cityObject.city isEqualToString:@""]) {
        cityObject.city = @"广州";
    }
    UIBarButtonItem *barBtn1=[[UIBarButtonItem alloc]initWithTitle:cityObject.city style:UIBarButtonItemStylePlain target:self action:@selector(pushCityView)];
    UIBarButtonItem *barBtn2=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"hk_drop_white.png"] style:UIBarButtonItemStylePlain target:self action:@selector(pushCityView)];
    //        self.navigationItem.leftBarButtonItem=barBtn1;
    self.navigationItem.leftBarButtonItems = @[barBtn1, barBtn2];
    
    [self initialization];
    
    [self connection];
    
    NSString * plistPath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)objectAtIndex:0]stringByAppendingPathComponent:@"usersList.plist"];
    if ([[NSFileManager defaultManager] fileExistsAtPath:plistPath] == YES){
        self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"hk_clock2.png"] style:UIBarButtonItemStylePlain target:self action:@selector(messagePush)];
    }
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    
    cityObject.sucessCity = @"";
}

- (void)addBottomView{
     UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(self.view.center.x - 60, self.view.bounds.size.height - 120, 120, 40)];
        __block int timeout = 2; //倒计时时间
        dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
        dispatch_source_t _timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0,queue);
        dispatch_source_set_timer(_timer,dispatch_walltime(NULL, 0),1.0*NSEC_PER_SEC, 0); //每秒执行
        dispatch_source_set_event_handler(_timer, ^{
            if(timeout<=0){ //倒计时结束，关闭
                dispatch_source_cancel(_timer);
                dispatch_async(dispatch_get_main_queue(), ^{
                    //设置界面的按钮显示 根据自己需求设置
                    [label removeFromSuperview];
                });
            }else{
                dispatch_async(dispatch_get_main_queue(), ^{
                    //设置界面的按钮显示 根据自己需求设置
                    
                    label.backgroundColor = [UIColor blackColor];
                    label.text = @"获取当前位置";
                    label.textAlignment = NSTextAlignmentCenter;
                    label.textColor = [UIColor whiteColor];
                    label.font = [UIFont boldSystemFontOfSize:16.0f];
                    label.layer.cornerRadius = 10;
                    label.layer.masksToBounds = YES;
                    [self.view addSubview:label];
                });
                timeout--;
            }
        });
        dispatch_resume(_timer);
}

//- (void)configMapView
//{
//    _mapLocationManager = [[AMapLocationManager alloc] init];
//    
//    [_mapLocationManager setDesiredAccuracy:kCLLocationAccuracyHundredMeters];
//    
//    [_mapLocationManager requestLocationWithReGeocode:YES completionBlock:^(CLLocation *location, AMapLocationReGeocode *regeocode, NSError *error) {
//        
//        if (error)
//        {
//            NSLog(@"locError:{%ld - %@};", (long)error.code, error.localizedDescription);
//            
//            if (error.code == AMapLocationErrorLocateFailed)
//            {
//                return;
//            }
//        }
//        
//        if (regeocode)
//        {
//            UIBarButtonItem *barBtn1=[[UIBarButtonItem alloc]initWithTitle:regeocode.city style:UIBarButtonItemStylePlain target:self action:@selector(pushCityView)];
//            UIBarButtonItem *barBtn2=[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"hk_drop_white.png"] style:UIBarButtonItemStylePlain target:self action:@selector(pushCityView)];
//            //        self.navigationItem.leftBarButtonItem=barBtn1;
//            self.navigationItem.leftBarButtonItems = @[barBtn1, barBtn2];
//        }
//    }];
//}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)pushCityView{
    CityViewController * setboardVC = [[UIStoryboard storyboardWithName:@"CityViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"CityViewController"];
    [self.navigationController pushViewController:setboardVC animated:YES];
}

- (void)messagePush{
    MessageViewController * messageboardVC = [[UIStoryboard storyboardWithName:@"MessageViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"MessageViewController"];
    
    messageboardVC.message = @"此验证码只用于订单完成，请勿在未完成订单前清除，653450,此验证码只用于订单完成，请勿在未完成订单前清除，653450";
    messageboardVC.message2 = @"2016-03-21 18:30:30";
    
    [self.navigationController pushViewController:messageboardVC animated:NO];
}

- (void)connection{
    NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
    [params setObject:@"0wtcDflIXFLHx4VJ3G32cuFGg" forKey:@"appSecret"];
    
    [self postRequestWithMethodName:@"auth/accesstoken" andParams:params andSender:nil];
}

- (void)initialization{
    _imageAddressArray = [NSMutableArray new];
    _imageData = [NSMutableData new];
    _imageViewArray = [NSMutableArray new];
    
    _recordTool = [LVRecordTool sharedRecordTool];
    _recordTool.delegate = self;
}

- (void)addImageView{
    for (int i = 0; i < _imageAddressArray.count; i ++) {
        //        [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:YES];
        NSString * urlString = [_imageAddressArray[i] objectForKey:@"banner_href"];
        NSURL *url = [NSURL URLWithString:
                      urlString];
        NSURLSessionDownloadTask *downloadPhotoTask =[[NSURLSession sharedSession]
                                                      downloadTaskWithURL:url completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) {
                                                          
                                                          NSLog(@"error = %@", error);
                                                          [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO];
                                                          
                                                          UIImage *downloadedImage = [UIImage imageWithData:
                                                                                      [NSData dataWithContentsOfURL:location]];
                                                          [_imageViewArray addObject:downloadedImage];
                                                          dispatch_async(dispatch_get_main_queue(), ^{
                                                              if (_imageViewArray.count == _imageAddressArray.count) {
                                                                  [self scrollViewLayout];
                                                              }
                                                              //                                                              [self scrollViewLayout];
                                                          });
                                                      }];
        [downloadPhotoTask resume];
        //        UIImageView * imageView = [[UIImageView alloc] init];
        ////        [imageView sd_setImageWithURL:url];
        ////        NSLog(@"imageView = %@", imageView);
        //        [imageView sd_setImageWithURL:url completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        //            [_imageViewArray addObject:image];
        //            if (_imageViewArray.count == _imageAddressArray.count) {
        //                [self scrollViewLayout];
        //            }
        //            [self scrollViewLayout];
        //        }];
    }
    //    if (_imageViewArray.count == 0) {
    //        [self addImageView];
    //        NSLog(@"12312313");
    //    }
}

- (void)updateUI{
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    if (screenHeight == 480) {
        _keyboardWidth.constant -= 20;
        _keyboardHeight.constant -= 20;
        _keyboardBottom.constant -= 50;
    }else if (screenHeight == 568){
        _keyboardBottom.constant -= 30;
        _picBottom.constant += 15;
    }else if (screenWidth == 375 && screenHeight == 667){
        _keyboardWidth.constant += 50;
        _keyboardHeight.constant += 50;
        _keyboardBottom.constant += 25;
        _picBottom.constant += 55;
    }else if (screenWidth == 414 && screenHeight == 736){
        _keyboardWidth.constant += 80;
        _keyboardHeight.constant += 80;
        _keyboardBottom.constant += 60;
        _picBottom.constant += 105;
    }
    
    _bottomView.layer.borderWidth = 1;
    _bottomView.layer.borderColor = [[[UIColor lightGrayColor] colorWithAlphaComponent:0.5] CGColor];
    _orderBackView.layer.borderWidth = 1;
    _orderBackView.layer.borderColor = [[[UIColor lightGrayColor] colorWithAlphaComponent:0.5] CGColor];
    _orderBackView.layer.cornerRadius = _orderBackView.frame.size.width / 2;
    
    UITapGestureRecognizer * orderTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    orderTapGestureRecognizer.numberOfTapsRequired = 1;
    [_orderImageView addGestureRecognizer:orderTapGestureRecognizer];
    _orderImageView.userInteractionEnabled = YES;
}

- (IBAction)pushController:(UIButton *)sender {
    PersonalViewController * personalboardVC = [[UIStoryboard storyboardWithName:@"PersonalViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"PersonalViewController"];
    [self.navigationController pushViewController:personalboardVC animated:NO];
}

- (void)tapAction:(UITapGestureRecognizer *)tapGestureRecognizer{
    if ([userObject.type isEqualToString:@"1"]) {
        OrderViewController * orderboardVC = [[UIStoryboard storyboardWithName:@"OrderViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"OrderViewController"];
        [self.navigationController pushViewController:orderboardVC animated:NO];
    }else if ([userObject.type isEqualToString:@"0"]){
        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"请申请成为速送员" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            PersonalViewController * personalboardVC = [[UIStoryboard storyboardWithName:@"PersonalViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"PersonalViewController"];
            [self.navigationController pushViewController:personalboardVC animated:NO];
        }];

        [alertVC addAction:action];
        [self presentViewController:alertVC animated:YES completion:nil];
    }else if (!userObject.userID){
        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"请先登录" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *action = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
            LoginViewController * personalboardVC = [[UIStoryboard storyboardWithName:@"LoginViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
            [self.navigationController pushViewController:personalboardVC animated:NO];
        }];
        
        [alertVC addAction:action];
        [self presentViewController:alertVC animated:YES completion:nil];
    }
}

- (void)loginPush{
    LoginViewController * loginboardVC = [[UIStoryboard storyboardWithName:@"LoginViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"LoginViewController"];
    [self.navigationController pushViewController:loginboardVC animated:YES];
}

- (IBAction)keyOrVoicePush:(UIButton *)sender {
    KeyboardViewController * keyboardVC = [[UIStoryboard storyboardWithName:@"KeyboardViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"KeyboardViewController"];
    
    keyboardVC.textOrSpeech = @"text";
    
    [self.navigationController pushViewController:keyboardVC animated:YES];
}

- (IBAction)recordBtnDidTouchDown:(UIButton *)sender {
    [self.recordTool startRecording];
}

- (IBAction)recordBtnDidTouchUpInside:(UIButton *)sender {
    _currentTime = self.recordTool.recorder.currentTime;
    
    if (_currentTime < 2) {
        [self alertViewShowWithAlertString:@"说话时间太短"];
        dispatch_async(dispatch_get_global_queue(0, 0), ^{
            
            [self.recordTool stopRecording];
            [self.recordTool destructionRecordingFile];
        });
    } else {
        
        dispatch_async(dispatch_get_global_queue(0, 0), ^{
            
            [self.recordTool stopRecording];
            dispatch_async(dispatch_get_main_queue(), ^{
                KeyboardViewController * keyboardVC = [[UIStoryboard storyboardWithName:@"KeyboardViewController" bundle:nil] instantiateViewControllerWithIdentifier:@"KeyboardViewController"];
                keyboardVC.homeViewController = self;
                
                keyboardVC.textOrSpeech = @"speech";
                
                [self.navigationController pushViewController:keyboardVC animated:YES];
            });
        });
    }
}

- (void)scrollViewLayout{
    if (![userObject.homeString isEqualToString:@"1"]) {
        userObject.homeString = @"1";
        userObject.homeArray = _imageViewArray;
        _imagesData = _imageViewArray;
    }else{
        _imagesData = userObject.homeArray;
    }
    
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    if (screenHeight == 480) {
        _myScrollView  = [[UIScrollView alloc] initWithFrame:naviFrame1];
    }else{
        _myScrollView  = [[UIScrollView alloc] initWithFrame:naviFrame2];
    }
    
    [_myScrollView setPagingEnabled:YES];
    [_myScrollView setDelegate:self];
    _myScrollView.showsVerticalScrollIndicator = NO;
    _myScrollView.showsHorizontalScrollIndicator = NO;
    [self.view addSubview:_myScrollView];
    
    UIImageView * backgroundImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.myScrollView.frame.size.height)];
    backgroundImageView.image = [self.imagesData lastObject];
    [_myScrollView addSubview:backgroundImageView];
    
    for (int i=0; i<[self.imagesData count]; i++) {
        UIImageView *subViews=[[UIImageView alloc] initWithImage:[self.imagesData objectAtIndex:i]];
        subViews.frame=CGRectMake(self.view.frame.size.width * (i + 1), 0, self.view.frame.size.width, _myScrollView.frame.size.height);
        [_myScrollView addSubview: subViews];
    }
    
    UIImageView *lastView=[[UIImageView alloc] initWithImage:[self.imagesData objectAtIndex:0]];
    lastView.frame=CGRectMake(self.view.frame.size.width * (_imagesData.count+1), 0, self.view.frame.size.width, _myScrollView.frame.size.height);
    [_myScrollView addSubview:lastView];
    
    [_myScrollView setContentSize:CGSizeMake(self.view.frame.size.width*(_imagesData.count + 2), _myScrollView.frame.size.height)];
    [self.view addSubview:_myScrollView];
    [_myScrollView scrollRectToVisible:CGRectMake(self.view.frame.size.width, 0, self.view.frame.size.width, _myScrollView.frame.size.height) animated:NO];
    
    _myPageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(_myScrollView.frame) - 20, self.view.frame.size.width, 20)];
    _myPageControl.currentPage = 0;
    _myPageControl.numberOfPages = _imagesData.count;
    _myPageControl.enabled = YES;
    [_myPageControl addTarget:self action:@selector(pageTurn:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:_myPageControl];
    
    _myTimer=[NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector:@selector(scrollToNextPage:) userInfo:nil repeats:YES];
}

#pragma UIScrollView delegate
-(void)scrollToNextPage:(id)sender
{
    NSInteger pageNum = self.myPageControl.currentPage;
    CGSize viewSize = self.myScrollView.frame.size;
    CGRect rect = CGRectMake((pageNum+2) * viewSize.width, 0, viewSize.width, viewSize.height);
    [_myScrollView scrollRectToVisible:rect animated:NO];
    pageNum++;
    if (pageNum == _imagesData.count) {
        CGRect newRect = CGRectMake(viewSize.width, 0, viewSize.width, viewSize.height);
        [_myScrollView scrollRectToVisible:newRect animated:NO];
    }
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    CGFloat pageWidth = _myScrollView.frame.size.width;
    int currentPage = floor((_myScrollView.contentOffset.x - pageWidth/2) / pageWidth) + 1;
    if (currentPage == 0) {
        _myPageControl.currentPage = _imagesData.count-1;
    }else if(currentPage == self.imagesData.count + 1){
        _myPageControl.currentPage = 0;
    }
    _myPageControl.currentPage = currentPage - 1;
    
}
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
    [_myTimer invalidate];
}
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    _myTimer = [NSTimer scheduledTimerWithTimeInterval:2.0f target:self selector:@selector(scrollToNextPage:) userInfo:nil repeats:YES];
}
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    CGFloat pageWidth = _myScrollView.frame.size.width;
    CGFloat pageHeigth = _myScrollView.frame.size.height;
    int currentPage = floor((_myScrollView.contentOffset.x - pageWidth/2)/pageWidth) + 1;
    
    if (currentPage == 0) {
        [_myScrollView scrollRectToVisible:CGRectMake(pageWidth * _imagesData.count, 0, pageWidth, pageHeigth) animated:NO];
        _myPageControl.currentPage = _imagesData.count - 1;
        
        return;
    }else  if(currentPage == [_imagesData count] + 1){
        [_myScrollView scrollRectToVisible:CGRectMake(pageWidth, 0, pageWidth, pageHeigth) animated:NO];
        _myPageControl.currentPage = 0;
        
        return;
    }
    _myPageControl.currentPage = currentPage - 1;
}

-(void)pageTurn:(UIPageControl *)sender
{
    NSInteger pageNum = _myPageControl.currentPage;
    CGSize viewSize = _myScrollView.frame.size;
    [_myScrollView setContentOffset:CGPointMake((pageNum + 1) * viewSize.width, 0)];
}

//- (void)cityTouch{
//    NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
//    NSString *documentsPath = [path objectAtIndex:0];
//    NSString *plistPath = [documentsPath stringByAppendingPathComponent:@"usersList.plist"];
//    NSMutableArray * cityArray2 = [[NSMutableArray alloc] initWithContentsOfFile:plistPath];
////    NSLog(@"cityArray2 = %@", cityArray2);
//    NSString * string = @"3";
//    if ([cityArray2 containsObject:string]) {
////        NSLog(@"contain!");
//    }else{
//        [cityArray2 addObject:string];
//        [cityArray2 writeToFile:plistPath atomically:YES];
//    }
//}

//网络连接返回数据
- (void)requestSuccessedWithResult:(id)result NSURLSessionTask:(NSURLSessionTask *)task sender:(id)sender{
    
    NSString * urlString = [NSString stringWithFormat:@"%@", task.currentRequest.URL];
    
    if ([result isKindOfClass:[NSDictionary class]]) {
        NSString * code = [NSString stringWithFormat:@"%@", [result objectForKey:@"retcode"]];
        if ([code isEqualToString:@"0"] && [urlString isEqualToString:[NSString stringWithFormat:@"%@%@", URLDoman, @"auth/accesstoken"]]){
            userObject.accessToken = [[result objectForKey:@"retmsg"] objectForKey:@"access_token"];
            
            NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
            [params setObject:[[result objectForKey:@"retmsg"] objectForKey:@"access_token"] forKey:@"token"];
            
            [self postRequestWithMethodName:@"banner/get" andParams:params andSender:nil];
        }else if ([urlString isEqualToString:[NSString stringWithFormat:@"%@%@", URLDoman, @"banner/get"]]){
            _imageAddressArray = [result objectForKey:@"retmsg"];
            
            NSString * token = userObject.accessToken;
            NSString * userIDString = userObject.userID;
            
            if (userIDString) {
                NSMutableDictionary *params = [[NSMutableDictionary alloc]init];
                [params setObject:token forKey:@"token"];
                [params setObject:userIDString forKey:@"uid"];
                
                [self postRequestWithMethodName:@"user/get_info" andParams:params andSender:nil];
            }
            if (![userObject.homeString isEqualToString:@"1"]) {
                [self addImageView];
            }
        }else if ([urlString isEqualToString:[NSString stringWithFormat:@"%@%@", URLDoman, @"user/get_info"]]){
            if (userObject.type == nil) {
                userObject.type = [NSString stringWithFormat:@"%@", [[result objectForKey:@"retmsg"] objectForKey:@"utype"]];
                if ([userObject.type isEqualToString:@"1"]) {
                    _orderImageView.image = [UIImage imageNamed:@"hk_grab.png"];
                    [self configMapView];
                }
            }else if ([userObject.type isEqualToString:@"1"]){
                [self configMapView];
            }
            
        }else if ([urlString isEqualToString:[NSString stringWithFormat:@"%@%@", URLDoman, @"order/upload_express_postion"]]){
            
        }
    }
}

@end
